package cn.yitun.chat.yitunserverrunsingleboot.chat.properties;

import cn.yitun.chat.yitunserverrunsingleboot.chat.factory.YamlPropertyLoaderFactory;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;

/**
 * 连接配置类
 * @author chenyitun
 * @date 2020-06-07
 */
@Data
@NoArgsConstructor
@Configuration
@PropertySource(value = {"classpath:config/config.yml"}, factory = YamlPropertyLoaderFactory.class, ignoreResourceNotFound = true)
//@ConfigurationProperties
public class ServerProperties {
    /**
     * server start
     */
    //端口
    @Value("${server.port}")
    private Integer serverPort;
    //端口对应代理服务名
    @Value("${server.proxy}")
    private String serverProxy;
    //服务器地址
    @Value("${server.config.address}")
    private String serverAddress;
    //tcp端口
    @Value("${server.config.chat.tcp.port}")
    private Integer tcpPort;
    //tcp端口对应代理服务名
    @Value("${server.config.chat.tcp.proxy}")
    private String tcpProxy;
    //udp端口
    @Value("${server.config.chat.udp.port}")
    private Integer udpPort;
    //udp端口对应代理服务名
    @Value("${server.config.chat.udp.proxy}")
    private String udpProxy;
    //websocket端口
    @Value("${server.config.chat.websocket.port}")
    private Integer websocketPort;
    //websocket端口对应代理服务名
    @Value("${server.config.chat.websocket.proxy}")
    private String websocketProxy;
    //websocket请求路径
    @Value("${server.config.chat.websocket.path}")
    private String websocketPath;
    //文件上传路径
    @Value("${server.config.file.upload.path}")
    private String fileUploadPath;
    //文件请求路径
    @Value("${server.config.file.request.path}")
    private String fileRequestPath;
    //远程调用端口
    @Value("${server.config.remote.tcp.port}")
    private Integer remoteTcpPort;
    //远程调用端口对应代理服务名
    @Value("${server.config.remote.tcp.proxy}")
    private String remoteTcpProxy;
    //是否可用
    @Value("${server.config.enabled}")
    private Boolean addressConfigEnabled;
    /**
     * server end
     */

    /**
     *  path start
     */
    @Value("${server.main.tcp.port}")
    private String mainTcpPort;
    @Value("${server.main.tcp.address}")
    private String mainTcpAddress;
    @Value("${server.main.websocket.address}")
    private String mainWebsocketAddress;
    @Value("${server.main.http.address}")
    private String mainHttpAddress;
    @Value("${server.api.http.address}")
    private String apiHttpAddress;
    @Value("${server.file.http.address}")
    private String fileHttpAddress;

    /**
     * path end
     */

    @Override
    public String toString() {
        return "ServerProperties{" +
                "serverPort=" + serverPort +
                ", serverProxy='" + serverProxy + '\'' +
                ", serverAddress='" + serverAddress + '\'' +
                ", tcpPort=" + tcpPort +
                ", tcpProxy='" + tcpProxy + '\'' +
                ", udpPort=" + udpPort +
                ", udpProxy='" + udpProxy + '\'' +
                ", websocketPort=" + websocketPort +
                ", websocketProxy='" + websocketProxy + '\'' +
                ", websocketPath='" + websocketPath + '\'' +
                ", fileUploadPath='" + fileUploadPath + '\'' +
                ", fileRequestPath='" + fileRequestPath + '\'' +
                ", remoteTcpPort=" + remoteTcpPort +
                ", remoteTcpProxy='" + remoteTcpProxy + '\'' +
                ", addressConfigEnabled=" + addressConfigEnabled +
                ", mainTcpPort='" + mainTcpPort + '\'' +
                ", mainTcpAddress='" + mainTcpAddress + '\'' +
                ", mainWebsocketAddress='" + mainWebsocketAddress + '\'' +
                ", mainHttpAddress='" + mainHttpAddress + '\'' +
                ", apiHttpAddress='" + apiHttpAddress + '\'' +
                ", fileHttpAddress='" + fileHttpAddress + '\'' +
                '}';
    }
}